using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Administration.Claims;
using Microsoft.SharePoint.Administration;
using System.Collections.Generic;
using Microsoft.Office.Server.UserProfiles;

namespace MMCP.Features.ClaimsFeature
{
    [Guid("16235921-27ce-4e4d-b29c-bda04ace0452")]
    public class ClaimsFeatureEventReceiver : SPClaimProviderFeatureReceiver
    {
        private void ExecBaseFeatureActivated(Microsoft.SharePoint.SPFeatureReceiverProperties properties)
        {
            //wrapper function for base FeatureActivated.  Used because base
            //keywork can lead to unverifiable code inside lambda expression

            base.FeatureActivated(properties);
        }

        public override string ClaimProviderAssembly
        {
            get { return typeof(MetaMembershipClaimProvider).Assembly.FullName; }
        }

        public override string ClaimProviderDescription
        {
            get { return "Meta Membership Claim Provider"; }
        }

        public override string ClaimProviderDisplayName
        {
            get
            {
                //this is where we reuse that internal static property
                return MetaMembershipClaimProvider.ProviderDisplayName;
            }
        }

        public override string ClaimProviderType
        {
            get { return typeof(MetaMembershipClaimProvider).FullName; }
        }

        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            ExecBaseFeatureActivated(properties);
        }

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            base.FeatureDeactivating(properties);

            //var localfarm = SPFarm.Local;
            //var config = localfarm.GetObject(new Guid(MMCPConfig.ObjectID)) as MMCPConfig;
            //config.Delete();
            //config.Unprovision();
        }
    }
}
